total = 0
for x in range(1,1000001):
	if (str(x) == str(x)[::-1]) and (bin(x)[2:] == bin(x)[:1:-1]):
		total = total + x
		print(x)
print("Total: "+str(total))